package com.iqiyi.pps.epg.core.model.program;

/**
 * Created by karkarrotxu on 2017/3/2.
 */

import com.iqiyi.kiwi.utils.Configuration;
import com.iqiyi.pps.epg.api.model.web.program.TProgramDirectorResource;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;
import java.sql.Timestamp;

@Entity
@Table(name = "program_director_resource")
@Cache(usage = CacheConcurrencyStrategy.NONE)
public class ProgramDirectorResource {
    public static final String DEFAULT_RESOURCE_NAME = Configuration.getString("director.backup.name");
    public static final String DEFAULT_RESOURCE_QIPU_ID = Configuration.getString("director.backup.qipuId");
    public static final long DEFAULT_RESOURCE_LEGO_ID = Configuration.getLong("director.backup.legoId");

    public static final int NON_DEFAULT_BACKUP = 0;
    public static final int IS_DEFAULT_BACKUP = 1;
    public static final int IS_BACKUP = 1;
    public static final int NON_BACKUP = 0;
    public static final int IS_DELETE = 1;

    public static final int SINGAL_TYPE_ZHIBO = 0;
    public static final int SINGAL_TYPE_DIANBO = 1;
    public static final int SINGAL_TYPE_LIUDIZHI = 2;

    public static final int NOTHING = -1;

    public static final int RESOURCE_TYPE_SIGNAL = 1;
    public static final int RESOURCE_TYPE_COMMENTARY = 2;
    /**
     * 实体版本标识
     */
    private int version = 0;

    private int id;
    private int directorId;
    private long programQipuId;
    private int signalType = 0;
    private String signalId = "";
    private long signalLegoId = 0;
    private String snapshotUrl = "";
    private int isBackup = 0;
    private int isDefaultBackup = 0;
    private String signalName = "";
    private String signalUrl = "";
    private String signalPreviewUrl = "";
    private String productStatusUrl = "";
    private int isDeleted = 0;
    private Timestamp addTime = new Timestamp(System.currentTimeMillis());
    private Timestamp updateTime = new Timestamp(System.currentTimeMillis());

    private int resourceType = 1;
    private String volumn = "0";
    private int status = 0;
	// pms175 2017/11/30
    private int playCounts;

    public TProgramDirectorResource toThriftEntity() {
        TProgramDirectorResource thriftEntity = new TProgramDirectorResource();
        thriftEntity.setAddTime(this.addTime == null ? "0" : this.addTime.toString());
        thriftEntity.setId(this.id);
        thriftEntity.setDirectorId(this.directorId);
        thriftEntity.setProgramQipuId(this.programQipuId);
        thriftEntity.setSignalLegoId(this.signalLegoId);
        thriftEntity.setSignalType(this.signalType);
        thriftEntity.setSignalId(this.signalId);
        thriftEntity.setSnapshotUrl(this.snapshotUrl);
        thriftEntity.setIsBackup(this.isBackup);
        thriftEntity.setIsDefaultBackup(this.isDefaultBackup);
        thriftEntity.setSignalName(this.signalName);
        thriftEntity.setSignalUrl(this.signalUrl);
        thriftEntity.setSignalPreviewUrl(this.signalPreviewUrl);
        thriftEntity.setProductStatusUrl(this.productStatusUrl);
        thriftEntity.setPlayCounts(this.playCounts);
        return thriftEntity;
    }

    public static ProgramDirectorResource createBackupResource(int directorId, long programQipuId) {
        ProgramDirectorResource resource = new ProgramDirectorResource();
        resource.setDirectorId(directorId);
        resource.setProgramQipuId(programQipuId);
        resource.setSignalLegoId(DEFAULT_RESOURCE_LEGO_ID);
        resource.setSignalType(1);
        resource.setSignalId(DEFAULT_RESOURCE_QIPU_ID);
        resource.setIsBackup(1);
        resource.setIsDefaultBackup(1);
        resource.setSignalName(DEFAULT_RESOURCE_NAME);
        return resource;
    }

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Column(name = "director_id")
    public int getDirectorId() {
        return directorId;
    }

    public void setDirectorId(int directorId) {
        this.directorId = directorId;
    }

    @Column(name = "program_qipu_id")
    public long getProgramQipuId() {
        return programQipuId;
    }

    public void setProgramQipuId(long programQipuId) {
        this.programQipuId = programQipuId;
    }

    @Column(name = "signal_type")
    public int getSignalType() {
        return signalType;
    }

    public void setSignalType(int signalType) {
        this.signalType = signalType;
    }

    @Column(name = "signal_id")
    public String getSignalId() {
        return signalId;
    }

    public void setSignalId(String signalId) {
        this.signalId = signalId;
    }

    @Column(name = "snapshot_url")
    public String getSnapshotUrl() {
        return snapshotUrl;
    }

    public void setSnapshotUrl(String snapshotUrl) {
        this.snapshotUrl = snapshotUrl;
    }


    @Column(name = "is_backup")
    public int getIsBackup() {
        return isBackup;
    }

    public void setIsBackup(int isBackup) {
        this.isBackup = isBackup;
    }

    @Column(name = "is_default_backup")
    public int getIsDefaultBackup() {
        return isDefaultBackup;
    }

    public void setIsDefaultBackup(int isDefaultBackup) {
        this.isDefaultBackup = isDefaultBackup;
    }

    @Column(name = "signal_name")
    public String getSignalName() {
        return signalName;
    }

    public void setSignalName(String signalName) {
        this.signalName = signalName;
    }

    @Column(name = "signal_url")
    public String getSignalUrl() {
        return signalUrl;
    }

    public void setSignalUrl(String signalUrl) {
        this.signalUrl = signalUrl;
    }

    @Column(name = "signal_preview_url")
    public String getSignalPreviewUrl() {
        return signalPreviewUrl;
    }

    public void setSignalPreviewUrl(String signalPreviewUrl) {
        this.signalPreviewUrl = signalPreviewUrl;
    }


    public void setProductStatusUrl(String productStatusUrl) {
        this.productStatusUrl = productStatusUrl;
    }

    public void setIsDeleted(int isDeleted) {
        this.isDeleted = isDeleted;
    }

    @Column(name = "product_status_url")
    public String getProductStatusUrl() {
        return productStatusUrl;
    }

    @Column(name = "is_deleted")
    public int getIsDeleted() {
        return isDeleted;
    }

    @Column(name = "add_time")
    public Timestamp getAddTime() {
        return addTime;
    }

    public void setAddTime(Timestamp addTime) {
        this.addTime = addTime;
    }

    @Column(name = "update_time", insertable = false, updatable = false)
    public Timestamp getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Timestamp updateTime) {
        this.updateTime = updateTime;
    }

    @Column(name = "signal_lego_id")
    public long getSignalLegoId() {
        return signalLegoId;
    }

    public void setSignalLegoId(long signalLegoId) {
        this.signalLegoId = signalLegoId;
    }

    @Version
    @Column(nullable = false)
    public Integer getVersion() {
        return version;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }

    @Column(name = "resource_type")
    public int getResourceType() {
        return resourceType;
    }

    public void setResourceType(int resourceType) {
        this.resourceType = resourceType;
    }

    @Column(name = "volumn")
    public String getVolumn() {
        return volumn;
    }

    public void setVolumn(String volumn) {
        this.volumn = volumn;
    }

    @Column(name = "status")
    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    @Column(name = "play_counts")
    public int getPlayCounts() {
        return playCounts;
    }

    public void setPlayCounts(int playCounts) {
        this.playCounts = playCounts;
    }
}
